import express from 'express';
//import React from 'react';
import path from 'path';

import {isoMiddleware} from './middleware/routerMiddleware'
import {hotMiddleware} from './middleware/devMiddleware'

import http from 'http';

var isDev = true;//process.env.NODE_ENV === 'development';
// import reactApp from '../src/router';

const app = express();

app.use('/static',express.static('./dist'));

const server = http.createServer(app)

app
  .set('view engine', 'ejs')
  .set('views', path.resolve(__dirname, 'views'))


if(isDev){
    app.use(hotMiddleware);
}

app.use(isoMiddleware);
// app.get('/',(req,res)=>{
//     res.status(200).render('index',{
//         root:'<h1>root test</h1>'
//     })
// });

server.listen(
    '4000',
    'localhost',
    (err)=>{
        console.log(err);
    }
)

// app.listen(4000,()=>{
//     console.log("start at 4000");
// })